<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <button>点击</button>
  <script>
    // constructor 里面的this指向创建的实例对象 , 方法里的this指向这个方法的调用者。***
    let that;
    class Star {
      constructor(uname) {
        // constructor 里面的this指向创建的实例对象
        console.log(this);
        this.uname = uname;
        this.btn = document.querySelector('button');
        this.btn.onclick = this.sing;
        that = this;

      }

      sing() {
        console.log(that.uname);
      }
    }

    const ldh = new Star('刘德华')
    ldh.sing();

  </script>
</body>
</html>